import os

from openai import OpenAI

client = OpenAI(
    base_url=os.getenv("MY_QWEN_BASE_URL"),
    api_key=os.environ["MY_QWEN_API_KEY"], # ModelScope Token
)

response = client.chat.completions.create(
    model='unsloth/DeepSeek-R1-Distill-Qwen-7B-GGUF', # ModelScope Model-Id
    messages=[
        {
            'role': 'system',
            'content': '你是一个厉害的AI助手.'
        },
        {
            'role': 'user',
            'content': '介绍一下你自己'
        }
    ],
    stream=True
)

for chunk in response:
    print(chunk.choices[0].delta.content, end='', flush=True)